package com.landinfo.domain;

import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;

import javax.persistence.*;
import java.io.Serializable;
import java.time.ZonedDateTime;
import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Set;

/**
 * dashboard配置
 */
@Entity
@Table(name = "dashboard_config")
public class DashboardConfiguration implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "id", length = 36)
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "custom-uuid")
    @GenericGenerator(name = "custom-uuid", strategy = "com.landinfo.web.rest.util.CustomUUIDGenerator")
    private String id;

    /**
     * 名称
     */
    @ApiModelProperty(value = "名称")
    @Column(name = "name")
    private String name;

    /**
     * 内容
     */
    @ApiModelProperty(value = "内容")
//    @Lob
    @Type(type = "org.hibernate.type.TextType")
    @Column(name = "content")
    private String content;

    /**
     * 排序
     */
    @ApiModelProperty(value = "排序")
    @Column(name = "sorting")
    private Integer sorting;

    /**
     * 模块名称
     */
    @ApiModelProperty(value = "模块名称")
    @Column(name = "module_name")
    private String moduleName;

    /**
     * 父级id
     */
    @ApiModelProperty(value = "父级id")
    @Column(name = "parent_id", length = 36)
    private String parentId;

    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    @Column(name = "remark")
    private String remark;

    /**
     * 备注2
     */
    @ApiModelProperty(value = "备注2")
    @Column(name = "remark_2")
    private String remark2;

    /**
     * 备注3
     */
    @ApiModelProperty(value = "备注3")
    @Lob
    @Column(name = "remark_3")
    private String remark3;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @Column(name = "create_date_time")
    private ZonedDateTime createDateTime;

    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间")
    @Column(name = "update_date_time")
    private ZonedDateTime updateDateTime;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name="parent_id")
    @OrderBy(value = "sorting")
    private Set<DashboardConfiguration> children = new LinkedHashSet<DashboardConfiguration>();

    // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public DashboardConfiguration name(String name) {
        this.name = name;
        return this;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getContent() {
        return content;
    }

    public DashboardConfiguration content(String content) {
        this.content = content;
        return this;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getModuleName() {
        return moduleName;
    }

    public DashboardConfiguration moduleName(String moduleName) {
        this.moduleName = moduleName;
        return this;
    }

    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
    }

    public String getParentId() {
        return parentId;
    }

    public DashboardConfiguration parentId(String parentId) {
        this.parentId = parentId;
        return this;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public String getRemark() {
        return remark;
    }

    public DashboardConfiguration remark(String remark) {
        this.remark = remark;
        return this;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getRemark2() {
        return remark2;
    }

    public DashboardConfiguration remark2(String remark2) {
        this.remark2 = remark2;
        return this;
    }

    public void setRemark2(String remark2) {
        this.remark2 = remark2;
    }

    public String getRemark3() {
        return remark3;
    }

    public DashboardConfiguration remark3(String remark3) {
        this.remark3 = remark3;
        return this;
    }

    public void setRemark3(String remark3) {
        this.remark3 = remark3;
    }

    public ZonedDateTime getCreateDateTime() {
        return createDateTime;
    }

    public DashboardConfiguration createDateTime(ZonedDateTime createDateTime) {
        this.createDateTime = createDateTime;
        return this;
    }

    public void setCreateDateTime(ZonedDateTime createDateTime) {
        this.createDateTime = createDateTime;
    }

    public ZonedDateTime getUpdateDateTime() {
        return updateDateTime;
    }

    public DashboardConfiguration updateDateTime(ZonedDateTime updateDateTime) {
        this.updateDateTime = updateDateTime;
        return this;
    }

    public void setUpdateDateTime(ZonedDateTime updateDateTime) {
        this.updateDateTime = updateDateTime;
    }
    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        DashboardConfiguration dashboardConfiguration = (DashboardConfiguration) o;
        if (dashboardConfiguration.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), dashboardConfiguration.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getId());
    }

    @Override
    public String toString() {
        return "DashboardConfiguration{" +
            "id=" + getId() +
            ", name='" + getName() + "'" +
            ", content='" + getContent() + "'" +
            ", moduleName='" + getModuleName() + "'" +
            ", parentId='" + getParentId() + "'" +
            ", remark='" + getRemark() + "'" +
            ", remark2='" + getRemark2() + "'" +
            ", remark3='" + getRemark3() + "'" +
            ", createDateTime='" + getCreateDateTime() + "'" +
            ", updateDateTime='" + getUpdateDateTime() + "'" +
            "}";
    }

    public Integer getSorting() {
        return sorting;
    }

    public void setSorting(Integer sorting) {
        this.sorting = sorting;
    }

    public Set<DashboardConfiguration> getChildren() {
        return children;
    }

    public void setChildren(Set<DashboardConfiguration> children) {
        this.children = children;
    }
}
